import {ADD_COUNTER,ADD_TO_CART} from './mutation-types'
export default {addCart(context,payload){
      return new Promise(((resolve, reject) => {
        let oldproduct=context.state.cart.find(item=>item.iid === payload.iid)
      if(oldproduct){
        context.commit(ADD_COUNTER,oldproduct)
        resolve('商品已经存在')
      }else {
        payload.count = 1
        context.commit(ADD_TO_CART,payload)
        resolve('商品添加成功')
      }
      }))
    }}
